package com.caigou.comm.base.ext

import android.graphics.Bitmap
import android.graphics.Canvas
import android.view.View

/**
 * @author #Suyghur.
 * Created on 2022/01/06
 */

fun View.screenCapture(): Bitmap {
    isDrawingCacheEnabled = true
    drawingCacheQuality = View.DRAWING_CACHE_QUALITY_HIGH
    val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
    val canvas = Canvas(bitmap)
    draw(canvas)
    isDrawingCacheEnabled = false
    destroyDrawingCache()
    return bitmap
}